﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" xmlns:Custom="http://www.galasoft.ch/mvvmlight" mc:Ignorable="d" x:Class="TinyWorkflow.UITests.MainWindow" Height="350" Width="525" Title="User's right management" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
	<Window.Resources>
		<DataTemplate x:Key="UserRightItemTemplate">
			<StackPanel Orientation="Horizontal" Margin="0,0,0,3">
				<TextBlock TextWrapping="Wrap" Text="{Binding User}" Margin="0,0,10,0" FontSize="14.667" FontWeight="Bold"/>
				<ItemsControl Height="Auto" ItemsSource="{Binding Rights}" ItemsPanel="{DynamicResource StackpanelItemsPanelTemplate}" ItemTemplate="{DynamicResource StringListItemTemplate}" VerticalAlignment="Center"/>
			</StackPanel>
		</DataTemplate>
		<ItemsPanelTemplate x:Key="StackpanelItemsPanelTemplate">
			<StackPanel IsItemsHost="True" Orientation="Horizontal"/>
		</ItemsPanelTemplate>
		<DataTemplate x:Key="StringListItemTemplate">
			<Grid>
				<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Mode=OneWay}" VerticalAlignment="Top" Margin="0,0,5,0"/>
			</Grid>
		</DataTemplate>
	</Window.Resources>
	<Window.DataContext>
		<Binding Mode="OneWay" Path="Main" Source="{StaticResource Locator}"/>
	</Window.DataContext>
    <Grid>
    	<VisualStateManager.VisualStateGroups>
    		<VisualStateGroup x:Name="LoadingVisualStateGroup">
    			<VisualStateGroup.Transitions>
    				<VisualTransition GeneratedDuration="0:0:0.8"/>
    			</VisualStateGroup.Transitions>
    			<VisualState x:Name="NotLoadingVisualState">
    				<Storyboard>
    					<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="LoadingGrid">
    						<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
    					</DoubleAnimationUsingKeyFrames>
    					<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" Storyboard.TargetName="LoadingGrid">
    						<DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
    					</BooleanAnimationUsingKeyFrames>
    				</Storyboard>
    			</VisualState>
    			<VisualState x:Name="LoadingVisualState">
    				<Storyboard>
    					<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" Storyboard.TargetName="LoadingGrid">
    						<DiscreteBooleanKeyFrame KeyTime="0" Value="True"/>
    					</BooleanAnimationUsingKeyFrames>
    					<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="LoadingGrid">
    						<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
    					</DoubleAnimationUsingKeyFrames>
    				</Storyboard>
    			</VisualState>
    		</VisualStateGroup>
    	</VisualStateManager.VisualStateGroups>
    	<Grid x:Name="DataGrid">
    		<i:Interaction.Triggers>
    			<i:EventTrigger>
    				<Custom:EventToCommand Command="{Binding InitializedCommand}"/>
    			</i:EventTrigger>
    		</i:Interaction.Triggers>
    		<ItemsControl HorizontalAlignment="Center" Height="250" VerticalAlignment="Center" Width="250" ItemsSource="{Binding MainState.UserRights}" ItemTemplate="{DynamicResource UserRightItemTemplate}"/>
    	</Grid>
    	<Grid x:Name="LoadingGrid">
    		<i:Interaction.Behaviors>
    			<ei:DataStateBehavior Binding="{Binding MainState.IsLoading}" Value="true" TrueState="LoadingVisualState" FalseState="NotLoadingVisualState"/>
    		</i:Interaction.Behaviors>
    		<Rectangle Stroke="Black" Fill="#CC9C9C9C"/>
    		<Grid HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="20">
    			<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Loading..." VerticalAlignment="Center" FontSize="48" FontWeight="Bold" Opacity="0.595" RenderTransformOrigin="0.5,0.5" Margin="0,-86,0,0">
    				<TextBlock.RenderTransform>
    					<TransformGroup>
    						<ScaleTransform/>
    						<SkewTransform AngleX="10"/>
    						<RotateTransform/>
    						<TranslateTransform/>
    					</TransformGroup>
    				</TextBlock.RenderTransform>
    			</TextBlock>
    			<ProgressBar Height="5" VerticalAlignment="Center" Maximum="{Binding MainState.MaxLoadingLevel}" Value="{Binding MainState.ActualLoadingLevel}" Foreground="#FF1C0680"/>
    			<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding MainState.LoadingString}" VerticalAlignment="Center" Margin="0,39,0,0"/>
    		</Grid>
    	</Grid>
        
    </Grid>
</Window>
